﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<DHAA.Areas.Administrator.Models.ProductModels>>" %>
<h3>Products</h3>
  <table class="list">
        <tr>
            <th>
                ProductImage
            </th>
           
            <th>
                ProductName
            </th>
            <th>
                CategoryName
            </th>
          
            <th>
                Price
            </th>
            <th>
                Description
            </th>
            
             <th>
                ID
            </th>
             <th>Actions</th>
        </tr>

    <% foreach (var item in Model) { %>
    
        <tr>
            <td>
              
       <% if (Html.Encode(item.ProductImage) != "")
{
    %> <a href="<%=ResolveUrl("~/Default/Imagesproduct/")%><%= Html.Encode(item.ProductImage) %>" class="ModalAction">
        <img src="<%=ResolveUrl("~/Default/Imagesproduct/")%><%= Html.Encode(item.ProductImage) %>" alt="<%=item.CategoryName %>" style="width: 80px; height:60px"/></a>
    <%
}else{ %>
<img src="<%=ResolveUrl("~/Content/images/")%>noImage.jpg" alt="No image" style="width: 80px; height:60px"/>


<%} %>
            </td>
          <td>
          <a href="<%= Url.Action("Details","Product", new{id = item.ProductID}) %>" class="ModalAction">
                <%= Html.Encode(item.ProductName) %>
            </a></td>
                 <td>
                 <a href="#<%= Url.Action("List", "Product", new{id = item.CategoryID}) %>" class="ajaxLink">
                <%= Html.Encode(item.CategoryName) %>
                </a>
            </td>                 
          
            <td>
                <%= Html.Encode(String.Format("{0:F}", item.Price)) %>
            </td>
            <td>
                <%= Html.Encode(item.Description) %>
            </td>
                 
             <td>
                <%= Html.Encode(item.ProductID) %>
            </td>
               <td>
                <%= Html.ActionLink("Edit", "Edit", new { id = item.ProductID },new {@class = "ModalAction"})%> |
                <%= Html.ActionLink("Details", "Details", new { id = item.ProductID }, new {@class = "ModalAction"})%> |
                <%= Html.ActionLink("Delete", "Delete", new { id = item.ProductID }, new { @class = "ModalAction" })%>
            </td>
        </tr>
    
    <% } %>

    </table>

    <p>
        <%= Html.ActionLink("Create New", "Create",new {id = Model.First().CategoryID}, new {@class = "ModalAction"}) %>
    </p>

